package com.ssm.common;

/**
 * Created by asus on 2017/7/13.
 */
public class ThisSystemUtil {
    public static String throwIfBlank(String message,String target){
        if(target==null||(target=target.trim()).length()==0){
            throw new ThisSystemException(message);
        }
        return target;
    }
    public static String $(String message,String target){
        return throwIfBlank(message,target);
    }

    public static void assertNotNull(String message,Object o){
        if(o==null){
            throw new ThisSystemException(message);
        }
    }

    public static void assertNull(String message,Object o){
        if(o!=null){
            throw new ThisSystemException(message);
        }
    }

    public static void assertEquals(String message,Object a,Object b){
        if(a==null?a!=b:!a.equals(b)){
            throw new ThisSystemException(message);
        }
    }

    public static void assertNotEquals(String message,Object a,Object b){
        if(a==null?a==b:a.equals(b)){
            throw new ThisSystemException(message);
        }
    }

    public static void assertTrue(String message,boolean b){
        if(!b){
            throw new ThisSystemException(message);
        }
    }
    public static void assertFalse(String message,boolean b){
        if(b){
            throw new ThisSystemException(message);
        }
    }
}
